// 子组件，展示列表
import React from 'react'
import actions from '../actions/actions'

const List = React.createClass({
	remove(i) {
		actions.remove(i);
	},
	render() {
		var items;
		var dataList = this.props.dataList
		if (dataList) {
			items = dataList.map((item, i) => {
				//设置key是因为react的diff算法，是通过key来计算最小变化的
				return <li key={i}>
          {item.name}
          <button onClick={this.remove.bind(this,i)}>remove</button>
        </li>
			})
		}
		return (
			<div>
				<ul>
					{items}
				</ul>
				<span>sadfsadfas</span>
			</div>
		)
	}
})

export default List;